﻿// Page00.cpp: 实现文件
//

#include "pch.h"
#include "wowlua01.h"
#include <string>
import game_lua;
#include "wnd_api.h"


// Page00 对话框

IMPLEMENT_DYNAMIC(Page00, CDialogEx)

Page00::Page00(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_DIALOG1, pParent)
	, luastring_(_T("")) {

}

Page00::~Page00()
{
}

void Page00::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT1, luastring_);
}


BEGIN_MESSAGE_MAP(Page00, CDialogEx)
	ON_BN_CLICKED(IDC_BTN_EXECUTE, &Page00::OnBnClickedBtnExecute)
END_MESSAGE_MAP()


// Page00 消息处理程序

std::string luastring;
#define TIME_ID 125
void CALLBACK lua_proc(HWND arg1, UINT arg2, UINT_PTR arg3_id, DWORD arg4) {
	//游戏主线程空间
	KillTimer(arg1, TIME_ID);
	__try {
		luaL_dostring(LUAPTR, luastring.c_str());
	} __except (1) {
		MessageBoxA(0, "可能是L指针需要更新", "出错", 0);
	}
}
void Page00::OnBnClickedBtnExecute() {
	// TODO: 在此添加控件通知处理程序代码
	UpdateData(TRUE);
	luastring = luastring_.GetBuffer();
	HWND hwnd = get_main_wnd("GxWindowClass");
	::SetTimer(hwnd, TIME_ID, 1, lua_proc);
}
